package com.pubinfo.passbook.api.controller.contract;

import com.pubinfo.passbook.common.model.dto.contract.ChangeUnitParam;
import com.pubinfo.passbook.common.model.dto.contract.SelectChangeUnitParam;
import com.pubinfo.passbook.common.model.vo.base.JsonResult;
import com.pubinfo.passbook.common.model.vo.base.MyPage;
import com.pubinfo.passbook.common.service.contract.TContractBaseService;
import com.pubinfo.passbook.common.service.master.ITFileChangeUnitService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.ParseException;

/**
 * @Author litiewang
 * @Date 2022/7/12 10:40
 * @Version 1.0
 */
@Slf4j
@RestController
@Api(tags = "QGPB-分析报表")
@RequestMapping(value = "contract-reports")
public class AnalyzeReportsController {
  
  @Resource
  private TContractBaseService contractBaseService;
  @Resource
  ITFileChangeUnitService itFileChangeUnitService;
  
  @PostMapping("exportStatement")
  @ApiOperation(value = "迁改单位催收报表导出")
  public void changeUnitExport(HttpServletResponse response, @RequestBody ChangeUnitParam changeUnitParam) throws IOException, ParseException {
    itFileChangeUnitService.changeUnitDownload(response, changeUnitParam);
  }
  
  @PostMapping("selectStatement")
  @ApiOperation(value = "查看迁改单位催收数据")
  public JsonResult<MyPage<SelectChangeUnitParam>> selectStatement(@RequestBody ChangeUnitParam changeUnitParam) throws ParseException {
    return JsonResult.success(new MyPage(itFileChangeUnitService.selectStatement(changeUnitParam)));
  }
}
